package db.view;


//Code Genarated by JGuiD
import java.awt.*;
import java.awt.event.*;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

import javax.swing.*;

public class sqleditor extends JFrame
{
    JLabel cont_i;
     JTextField cont_idv;
     JTextArea sqlv;
     JButton genreport;
     JButton quit;
     Properties pro;
     
   public sqleditor()
   {
	   
     getContentPane().setLayout(null);
     setupGUI();
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }
   void setupGUI()
   {
     	cont_i = new JLabel();
	cont_i.setLocation(66,44);
	cont_i.setSize(92,32);
	cont_i.setText("MDM-Cont_id");
	cont_i.setToolTipText("$MDM Party Id ");
	getContentPane().add(cont_i);

	cont_idv = new JTextField();
	cont_idv.setLocation(209,44);
	cont_idv.setSize(196,31);
	cont_idv.setText("MDM party ID");
	cont_idv.setColumns(10);
	getContentPane().add(cont_idv);

	sqlv = new JTextArea();
	sqlv.setLocation(52,102);
	sqlv.setSize(439,378);
	sqlv.setText("specify \"?\" in placed of cont_id in sql");
	sqlv.setRows(5);
	sqlv.setColumns(5);
	sqlv.setToolTipText("$Drag SQL file or copy SQL specify \"?\" in placed of cont_id in sql   ");
	getContentPane().add(sqlv);

	genreport = new JButton();
	genreport.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			
			SQLHtmlFormatter.tsql=sqlv.getText();
			SQLHtmlFormatter.tpartyid=cont_idv.getText();
			FileWriter fstream = null;
			  BufferedWriter out = null;
			try {
				 fstream = new FileWriter("sql.txt",false);
				   out = new BufferedWriter(fstream);
				  out.write(SQLHtmlFormatter.tsql);//printing path=" " for empty value --@@--
					
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			finally
			{
				try {
					out.close();
					fstream.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
			setVisible(false);
			SQLHtmlFormatter.main1();
		}
	});
	genreport.setLocation(120,509);
	genreport.setSize(138,32);
	genreport.setText("GenerateReport");
	getContentPane().add(genreport);

	quit = new JButton();
	quit.setLocation(290,508);
	quit.setSize(131,33);
	quit.setText("Quit");
	getContentPane().add(quit);

	setTitle("SQL Editor");
	setSize(569,617);
	setVisible(true);
	setResizable(true);
	
	
   }
    public static void main( String args[] )
   {
     new sqleditor();
   }
}  
